CycloidPlotter - Draw epicycloidal gears
Copyright 2008 by Hugh Sparks. All rights reserved.

Introduction

	This is a very quick and dirty program to plot
	a pair of gear teeth with true epicyloidal 
	addenda. It is not a polished piece of work, so
	you must expect to endure a little study to use
	it for your application.

	Please keep in mind that for various reasons,
	real clock and watch gears are never designed
	using true epicycloidal profiles. For more
	information, see:

	http://www.csparks.com/watchmaking/CycloidalGears/index.jhtml

	The program is not robust and will give you only cryptic
	error messages if the files you give it contain errors.
	If you get frustrated, start with a file that works and
	gradually transform it into what you want. Keep backups.

	If I get enough positive (or negative!) feedback, I'll
	make a better version someday.

Running the program

	There are two demo files included:

		DemoOneWheel.txt
		DemoFourWheels.txt

	To draw the wheel teeth, drag-n-drop one of the
	demo files on top of the CycloidPlotter.exe
	program icon.

	To plot your own gear design, I suggest you make
	a copy of the DemoOneWheel.txt file and rename it
	to something meaningful to your application. Then
	you can edit the file to specify your parameters.
	
	You must edit the files using a plain text editor
	such as Notepad. If you edit and save the file using
	Microsoft Word, the file will be ruined for use with
	this program.

Protocol for the expressions used in the demo files:

About units

	The module, and the screen pitch must be specified
	in the same system of units: mm, inches, feet, etc. 

GraphWindow.new[maxPoints]

	Create a new window. The maxPoints parameter determines
	the maximum number of points that may be plotted.
	You can make this a nice huge number unless you have
	extremely limited memory. The value must be an integer.

aGraphWindow.at[x, y]

	Position the window on the desktop.
	The parameters are in integer pixels.
	The window is enlarged or reduced to display the
	plot range give the magification setting.

aGraphWindow.setName[aTitleString]

	Set the name that appears in the windows's title bar.
	The value must be a string in single quotes: 'My Name'

aGraphWindow.setBorder[borderWidth]

	This enlarges the window to give you a white border around
	the plot. The value must be an integer number of pixels.

aGraphWindow.setMag[magnification]

	Blow up the range to fill the window.
	The value must be a real number.
	A value of 1.0 will plot the gears actual size,
	which might be too small for your screen resolution
	unless you are making really big gears.

aGraphWindow.setPitch[pixelSize]

	This controls the how the tooth drawn on the screen
	relates to the actual size. You need to lookup this
	value in the specifications for your monitor. If you
	are using inches for your parameters, a typical value
	would be 1.0/90.0 (90 pixels per inch)

	If you are creating templates on a printer, the
	pitch can be used as a fudge factor to get the
	print size right. The magnification parameter can
	be kept a nice even number that way.

	The pixelSize must be specified in the same units as
	the module. The value must be a real number.

aGraphWindow.draw

	Draw the window on the desktop.
	Whatever has been plotted will be drawn inside.

Wheel.new

	Create a new wheel

aWheel.setGeometry[module, numberOfWheelTeeth, numberOfPinionTeeth]

	Design a wheel.
	The module must be a real number in your chosen system of
	units. The number of teeth parameters must be integers.

	Recall that module = pitchDiameter/numberOfTeeth

aWheel.generate[nPoints]

	Generate the data for drawing a a tooth.
	The nPoints parameter controls how many points
	along the addendum curve are used. Smaller values
	will make the plot look jagged. Absurdly large values
	will take a long time to plot and you won't see any
	improvement in the drawing. About 200 looks good in
	most cases.

	The value must be an integer.

aWheel.plot[aGraphWindow]

	Creates a drawing of two teeth in a GraphWindow.
	If the graph window is already visible on the screen,
	the new plot does not appear until you tell the window
	to update the display using the expression (for example)
		
		g.drawGraph

	You can plot several wheels on the same graph before
	updating the display. If your files end with an expression
	like "g.draw" you don't need to bother with the drawGraph
	message because it happens automatically when the window
	is drawn or uncovered by other windows.

